<template>
	<view>
		<k-scroll-view ref="k-scroll-view" @onPullDown="handlePullDown" :emptyTip="emptyTip" :bottom="bottom"
			:autoPullUp="true" @onPullUp="handleLoadMore">
			<!-- <view style='padding:10px 15px;background-color: white;'>
				<u-search placeholder="请输入查询条件" v-model="keyword" shape="round" :showAction="true" actionText="搜索"
					:animation="false" height='60' style='width:100%' @focus='focusSearch'></u-search>
			</view> -->
			<view class="planAudit">
				<view style="border-top: 1px #E7E7E7 solid;padding: 0 0 0 20px;">
					<u-tabs :list="list1" @click='recordClick' lineWidth="40" lineHeight="6" lineColor="#108EEF"
						:activeStyle="{
				    color: '#303133',
				    fontWeight: 'bold',
				    transform: 'scale(1.05)'
				}"></u-tabs>
				</view>
				<view class="planAudit_project" v-for="(item,index) in checkTask">
					<view class="planAudit_project_title">
						<image class='planAudit_project_img'  src="/static/dailySupervision/tjbg.png" alt="" />
						<text>{{item.releaseTitle}}</text>
					</view>
					<view class="planAudit_project_content" style="width: 40%;">
						<text class='planAudit_project_text'>企业数</text>
						<text class='planAudit_project_text'>发布状态</text>
						<text class='planAudit_project_text'>发布日期</text>
					</view>
					<view class="planAudit_project_content" style="width: 60%;">
						<text class='planAudit_project_text'>{{item.assResultDetailCount}}</text>
						<text class='planAudit_project_text' @click="maintenanceClick(index)"
							style="color:#1590EF;">{{item.releaseState==0?'待审核':'已审核'}}</text>
						<text class='planAudit_project_text'>{{item.releaseTime==""?'无':item.releaseTime}}</text>

					</view>
				</view>
			</view>
		</k-scroll-view>
	</view>
</template>

<script>
	import * as api from '@/common/api/personnel.js'
	import kScrollView from '@/components/k-scroll-view/k-scroll-view.vue';
	export default {
		components: {
			kScrollView
		},
		data() {
			return {
				keyword: "",
				list1: [{
					name: '待审核',
				}, {
					name: '已审核',
				}, ],
				tabsIndex: 0,
				options: {},
				checkTask: [],
				emptyTip: '- -已经没有数据啦- -',
				bottom: 200,
				page: {
					"current": 1,
					"size": 10
				},
				pages: '',
				num: 1,
				audit: 1
			}
		},
		onLoad(option) {
			if (option.direction == 2) {
				this.options = JSON.parse(option.formSearch)
			} else {
				this.options = option
			}
		},
		mounted() {
			this.search(0)
		},
		methods: {
			search(index) {
				this.options.releaseState = index
				api.default.getInformationList({
					...this.options,
					...this.page
				}).then(res => {
					this.checkTask = res.data.data.records
					this.pages = res.data.data.pages
				})
			},

			// 导航切换
			recordClick(itme) {
				this.tabsIndex = itme.index
				if (itme.index == 0) {
					this.search(0)
				} else if (itme.index == 1) {
					this.search(1)
				}

			},
			// 下拉刷新
			handlePullDown(stopLoad) {
				if (this.tabsIndex == 0) {
					this.search(0)
				} else {
					this.search(1)
				}
			},

			// 上拉刷新
			handleLoadMore(stopLoad) {
				if (this.tabsIndex == 0) {
					this.options.releaseState = 0
					this.num += 1
					if (this.num <= this.pages) {
						api.default.getInformationList({
							"current": this.num,
							"size": 10,
							...this.options
						}).then(res => {
							this.checkTask = this.checkTask.concat(res.data.data.records);
						})
					} else {
						stopLoad ? stopLoad({
							isEnd: true
						}) : '';
					}
				} else {
					this.options.releaseState = 1
					this.audit += 1
					if (this.audit <= this.pages) {
						api.default.getInformationList({
							"current": this.audit,
							"size": 10,
							...this.options
						}).then(res => {
							this.checkTask = this.checkTask.concat(res.data.data.records);
						})
					} else {
						stopLoad ? stopLoad({
							isEnd: true
						}) : '';
					}
				}


			},

			//详情
			maintenanceClick(index) {
				this.$goBack('./subsystemView?status=' + this.checkTask[index].releaseState + '&resultId=' + this
					.checkTask[index].resultId + '&id=' + this.checkTask[index].id, 2);
			},

			// // // 我的任务查询跳转
			// focusSearch() {
			// 	this.$goBack('./search?releaseState=0&resultId=' + this.options.resultId, 5);
			// }
		}
	}
</script>

<style lang="scss" scoped>
	.planAudit {
		width: 100%;

		.planAudit_project {
			margin: 20rpx 35rpx;
			background-color: white;
			border-bottom: 1px #F2F2F2 solid;

			.planAudit_project_title {
				width: 100%;
				padding: 10px 0;
				display: inline-block;

				.planAudit_project_img {
					width: 30rpx;
					height: 40rpx;
					margin: 0 25rpx 0 20rpx;
					vertical-align: middle
				}
			}

			.planAudit_project_content {
				display: inline-block;
				margin: 10px 0;

				.planAudit_project_text {
					width: 100%;
					display: block;
					margin: 20rpx;
					overflow: hidden;
					white-space: nowrap;
					text-overflow: ellipsis
				}
			}
		}
	}
</style>
